﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace SELF.Controls
{
    public partial class HisSumary : DevExpress.XtraEditors.XtraForm
    {
        public HisSumary()
        {
            InitializeComponent();
        }

        private void rectangleShape1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private string _TicketID;

        public string TicketID
        {
            get { return _TicketID; }
            set { _TicketID = value; }
        }

        lcmpt.Connection Conn = new lcmpt.Connection();
        private void HisSumary_Load(object sender, EventArgs e)
        {
            DataSet dsData = GetSummary(_TicketID);
            FillGrid(dsData);
        }

        private DataSet GetSummary(string ticket)
        {
            try
            {
                DataSet ds = new DataSet();
                string sqlHistory = "EXECUTE [dbo].[sp_Get_CoursesSummary] '@Ticket'";
                sqlHistory = sqlHistory.Replace("@Ticket", TicketID);
                ds = Conn.Retreive(sqlHistory);
                return ds;
            }
            catch
            {
                DataSet ds = new DataSet();
                return ds;
            }
        }

        private void FillGrid(DataSet dsData)
        {
            CoreEngine.Util.DevExpressDataGridUtil.Fill(gridControl1, dsData);
            CoreEngine.Util.DevExpressDataGridUtil _config = new CoreEngine.Util.DevExpressDataGridUtil();
            _config.SetParameterColumn("TypeCourse", "ประเภทคอร์ส", true, 100, DevExpress.Utils.HorzAlignment.Center);
            _config.SetParameterColumn("CourseName", "ชื่อคอร์ส", true, 100, DevExpress.Utils.HorzAlignment.Center);
            _config.SetParameterColumn("LectureName", "ครั้งที่", true, 100, DevExpress.Utils.HorzAlignment.Center);
            _config.SetParameterColumn("Description", "รายละเอียด", true, 100, DevExpress.Utils.HorzAlignment.Center);
            _config.SetParameterColumn("UseTime", "รวมเรียน", true, 100, DevExpress.Utils.HorzAlignment.Center);
            _config.GridViewRanderConfig(gridView1);
            CoreEngine.Util.DevExpressDataGridUtil.BestFitAllColumn(gridView1);
        }

        private void panel1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}